/**
 * FileName: UserParser
 * Author:   powersi
 * Date:     2020/12/22 20:34
 * Description: UserParser
 */
package com.zm.demo.spring.configure.metadata.xsd;

import com.zm.demo.spring.configure.metadata.User;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

/**
 * Description: UserParser
 * Author:      powersi
 * Date:        2020/12/22 20:34
 */
public class UserBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {

    @Override
    protected Class<?> getBeanClass(Element element) {
        return User.class;
    }

    @Override
    protected void doParse(Element element, BeanDefinitionBuilder builder) {
        builder.addPropertyValue("name", element.getAttribute("name"));
        builder.addPropertyValue("id", element.getAttribute("id"));
    }
}
